Skip to content

Comments

feat: move sonar to separate job RAT-358#30

Merged
Riippi merged 3 commits intomainfrom
feat/RAT-358-sonar-job
Feb 24, 2026
Merged

feat: move sonar to separate job RAT-358#30
Riippi merged 3 commits intomainfrom
feat/RAT-358-sonar-job

Conversation

@Riippi
Copy link
Contributor

@Riippi Riippi commented Feb 23, 2026

Move sonarcoud to a separate job.

Refs: RAT-358 https://helsinkisolutionoffice.atlassian.net/browse/RAT-358

Similar change done to backend: #24

There are two PR:s where I used a copy of this .yml to test that sonar is run and uses the coverage info.
These have in purpose new functios that don't have 100% test coverage. I will delete these later.
City-of-Helsinki/open-city-profile-ui#492
City-of-Helsinki/linkedcomponents-ui#561

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the CI workflow for Node.js projects by separating SonarQube Cloud scanning into a dedicated job. Previously, the SonarQube scan ran as a conditional step within the tests job. The new structure creates a separate sonarcloud job that depends on the tests job, with coverage reports passed between jobs using GitHub Actions cache.

Changes:

  • Separated SonarQube Cloud scanning into a dedicated job that runs after tests complete
  • Added caching mechanism to transfer coverage reports from tests job to sonarcloud job
  • Added path override logic to fix SonarQube source path warnings for Node.js coverage files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 179 to 197
path: ${{ (inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory) && format('{0}/', inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory) || ''}}coverage
key: cache-${{ github.run_id }}-${{ github.run_attempt }}

sonarcloud:
name: Run SonarQube Cloud Scan
if: ${{ !inputs.skip_sonar }}
runs-on: ubuntu-latest
needs: tests
defaults:
run:
working-directory: ${{ inputs.working-directory }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Restore coverage report
uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
path: ${{ (inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory) && format('{0}/', inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory) || ''}}coverage
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The complex path construction expression ${{ (inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory) && format('{0}/', inputs.app-directory == '.' && inputs.working-directory || inputs.app-directory) || ''}}coverage is duplicated between lines 179 and 197. This duplication makes the workflow harder to maintain and increases the risk of inconsistencies if one instance is updated but not the other. While GitHub Actions doesn't support workflow-level variables for reusable expressions, consider adding a comment explaining the logic or simplifying the expression if possible.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments.

Comment on lines 138 to 139
with:
fetch-depth: 0
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fetch-depth: 0 is required for SonarQube Cloud scanning but was added to the tests job. Since the SonarQube scan has been moved to a separate job that already has its own checkout with fetch-depth: 0 (line 191-193), this setting in the tests job is now redundant. Consider removing it from the tests job checkout to speed up the checkout process, unless there's another reason the full git history is needed in the tests job.

Suggested change
with:
fetch-depth: 0

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the mentioned lines as suggested.

@Riippi Riippi requested a review from a team February 24, 2026 11:59
@Riippi Riippi merged commit 97d093a into main Feb 24, 2026
@Riippi Riippi deleted the feat/RAT-358-sonar-job branch February 24, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants